// <copyright file="DungeonGenerator.Predefines.cs" company="TenneySoftware">
// Copyright (c) 2009 All Right Reserved
// </copyright>
// <author>Robert Tenney</author>
// <email>rob10e@yahoo.com</email>
// <date>April 2009</date>
// <summary>Dungeon level generator.</summary>

// License:

// Product: RPGRoguelikeEngine .Net
// Author: Robert N. Tenney
// Copyright: April 2009

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation version 2
// of the License.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

// This license covers all source code, binaries, and other materials related to this project
// unless specifically stated otherwise.

using System;
using System.Collections.Generic;
using System.Globalization;

namespace TenneySoftware.LevelGenerator.DungeonGenerator {
    /// <content>
    /// This file contains the Predefined Settings methods for the generator.
    /// </content>
    public partial class Dungeon {
        /// <summary>
        /// Predefined method that returns a Predefined Settings object defined with caverns settings.
        /// </summary>
        public void PredefinedSettingsCaverns() {
            this.structureWeights = new Dictionary<StructureType, double>();
            this.SetStructureWeight(StructureType.Hall, 16);
            this.SetStructureWeight(StructureType.LongHall, 16);
            this.SetStructureWeight(StructureType.WanderingHall, 7);
            this.SetStructureWeight(StructureType.SmallRoom, 2);
            this.SetStructureWeight(StructureType.Room, 13);
            this.SetStructureWeight(StructureType.LargeRoom, 7);
            this.SetStructureWeight(StructureType.HugeRoom, 2);
            this.SetStructureWeight(StructureType.CircularSmallRoom, 2);
            this.SetStructureWeight(StructureType.CircularRoom, 12);
            this.SetStructureWeight(StructureType.CircularLargeRoom, 7);
            this.SetStructureWeight(StructureType.CircularHugeRoom, 2);
            this.SetStructureWeight(StructureType.Cave, 2);
            this.SetStructureWeight(StructureType.LargeCave, 12);
            this.Density = 10;
            this.RoomBias = 25;
            this.UsePreferredConnectors = 50;
            this.RemoveDeadEnds = true;
            this.SetName("Caverns");
        }

        /// <summary>
        /// Predefined method that returns a Predefined Settings object defined with default settings.
        /// </summary>
        public void PredefinedSettingsDefault() {
            this.structureWeights = new Dictionary<StructureType, double>();
            this.SetStructureWeight(StructureType.Hall, 16);
            this.SetStructureWeight(StructureType.LongHall, 16);
            this.SetStructureWeight(StructureType.WanderingHall, 11);
            this.SetStructureWeight(StructureType.SmallRoom, 2);
            this.SetStructureWeight(StructureType.Room, 15);
            this.SetStructureWeight(StructureType.LargeRoom, 17);
            this.SetStructureWeight(StructureType.HugeRoom, 2);
            this.SetStructureWeight(StructureType.CircularSmallRoom, 2);
            this.SetStructureWeight(StructureType.CircularRoom, 10);
            this.SetStructureWeight(StructureType.CircularLargeRoom, 7);
            this.SetStructureWeight(StructureType.CircularHugeRoom, 2);
            this.Density = 10;
            this.RoomBias = 25;
            this.UsePreferredConnectors = 75;
            this.RemoveDeadEnds = true;
            this.SetName("Default");
        }

        /// <summary>
        /// Predefined method that returns a Predefined Settings object defined with settings designed for a
        /// labyrinth type of dungeon.
        /// </summary>
        public void PredefinedSettingsLabyrinth() {
            this.structureWeights = new Dictionary<StructureType, double>();
            this.SetStructureWeight(StructureType.WanderingHall, 15);
            this.SetStructureWeight(StructureType.Hall, 10);
            this.EqualizeStructureWeights();
            this.RemoveDeadEnds = false;
            this.Density = 100;
            this.IntersectWanderingHalls = false;
            this.SetName("Labyrinth");
        }

        /// <summary>
        /// Predefined method that returns a Predefined Settings object defined with settings designed for a
        /// prison type of dungeon.
        /// </summary>
        public void PredefinedSettingsPrison() {
            this.structureWeights = new Dictionary<StructureType, double>();
            this.SetStructureWeight(StructureType.LongHall, 45);
            this.SetStructureWeight(StructureType.SmallRoom, 45);
            this.SetStructureWeight(StructureType.CircularLargeRoom, 5);
            this.SetStructureWeight(StructureType.WanderingHall, 5);
            this.RoomBias = 0;
            this.UsePreferredConnectors = 100;
            this.EqualizeStructureWeights();
            this.Density = 100;
            this.RemoveDeadEnds = true;
            this.SetName("Prison");
        }

        /// <summary>
        /// Predefined method that returns a Predefined Settings object defined with settings designed for a
        /// catacombs type of dungeon.
        /// </summary>
        public void PredefinedSettingsCatacombs() {
            this.structureWeights = new Dictionary<StructureType, double>();
            this.SetStructureWeight(StructureType.LongHall, 45);
            this.SetStructureWeight(StructureType.LongCave, 45);
            this.SetStructureWeight(StructureType.CircularLargeRoom, 5);
            this.SetStructureWeight(StructureType.WanderingHall, 5);
            this.RoomBias = 0;
            this.UsePreferredConnectors = 100;
            this.EqualizeStructureWeights();
            this.Density = 100;
            this.RemoveDeadEnds = true;
            this.SetName("Catacombs");
        }

        /// <summary>
        /// Predefined method that returns a Predefined Settings object defined with settings designed for a
        /// simple type of dungeon.
        /// </summary>
        public void PredefinedSettingsSimple() {
            this.structureWeights = new Dictionary<StructureType, double>();
            this.SetStructureWeight(StructureType.Hall, 50);
            this.SetStructureWeight(StructureType.SmallRoom, 25);
            this.SetStructureWeight(StructureType.Room, 25);
            this.RoomBias = 25;
            this.UsePreferredConnectors = 50;
            this.EqualizeStructureWeights();
            this.Density = 50;
            this.RemoveDeadEnds = false;
            this.SetName("Simple");
        }

        /// <summary>
        /// Retrieves a list of Predefined settings associated with this generator.
        /// </summary>
        /// <returns>An array of GeneratorData objects with information about the predefines within this generator.</returns>
        public GeneratorData[] GetPredefinedInformation() {
            GeneratorData[] result = new GeneratorData[6];
            result[0] = new GeneratorData(0, "Default", "Settings to generate a well rounded level with all of the features.", null);
            result[1] = new GeneratorData(1, "Labyrinth", "Settings to generate a level comprised mostly of twisting hallways.", null);
            result[2] = new GeneratorData(2, "Prison", "Settings to generate a level that has many small rooms off of hallways for cells, with a couple larger rooms for guardrooms.", null);
            result[3] = new GeneratorData(3, "Catacombs", "Settings to generate a level that has many small caverns off of hallways for tombs, with a couple larger rooms.", null);
            result[4] = new GeneratorData(4, "Caverns", "Settings to generate a level that is similar to default, with caverns thrown into the mix.", null);
            result[5] = new GeneratorData(5, "Simple", "Settings to generate a simplistic, no frills level.", null);
            return result;
        }

        /// <summary>
        /// Uses one of the many predefined settings for this generator. Available predefines are:
        /// 0 - Default
        /// 1 - Labyrinth
        /// 2 - Prison
        /// 3 - Catacombs
        /// 4 - Caverns
        /// 5 - Simple
        /// Usage: UsePredefinedSettings(1);
        /// Will use the Labyrinth predefined.
        /// </summary>
        /// <param name="predefined">Predefined value code to use.</param>
        public void UsePredefinedSettings(int predefined) {
            switch (predefined) {
                case 0:
                    this.PredefinedSettingsDefault();
                    break;
                case 1:
                    this.PredefinedSettingsLabyrinth();
                    break;
                case 2:
                    this.PredefinedSettingsPrison();
                    break;
                case 3:
                    this.PredefinedSettingsCatacombs();
                    break;
                case 4:
                    this.PredefinedSettingsCaverns();
                    break;
                case 5:
                    this.PredefinedSettingsSimple();
                    break;
                default:
                    throw new ArgumentOutOfRangeException("There are only 3 predefines defined. You entered: " +
                                                          predefined.ToString(CultureInfo.InvariantCulture));
            }
        }
    }
}
